﻿@{
    Layout = "../Shared/_Default.cshtml";
    ViewBag.PageTitle = T(Res.Name("Title"), JDM.Int64(Model.Posts.TotalCount));
}

@section Toolbar
{
    @if(Svc.IsAuthenticated && Svc.PublicationAuthor != null)
    {
        <a href="@Url.Action(Loc.Act("Create").Ctrl("BlogPost").Area("Wizard").Localized())">@T(Res.Name("Post"))</a>
    }
}
@section Sidebar
{
    @if(Model.Author != null)
    {
        Html.RenderAction(Loc.Act("_Overview").Ctrl("Account").NoArea().Set(new
        {
            id = JDM.Int32(Model.Author.Account.EntityID)
        }).Localized());
    }
    <div class="box">
        <header>
            <h3>@T(Res.Name("Archive"))</h3>
        </header>
        <section>
        @{
            Html.RenderAction(Loc.Act("_Archive").Set(new
            {
                 id = Model.Author != null 
                    ? JDM.Int32(Model.Author.EntityID)
                    : null
            }).Localized());
        }
        </section>
    </div>
}
<div class="box">
    <section>
    @{
        Html.RenderPartial("_List", (object)Model.Posts);
        Html.RenderPartial("_Pager", new ViewDataDictionary 
        { 
            { "PageNum", 6 },
            { "PageCount", Math.Ceiling(JDM.Double(Model.Posts.TotalCount) / Model.CountPerPage) }, 
            { "PageIndex", Request.QueryParam("page", 0) },
            { "PageParam", "page" },
            { "PageSize", Model.CountPerPage },
            { "PageRoute", Loc.Act("Index").Use("id", 
                "tagID", "attributeIDs", "searchTerm", 
                "dtFrom", "dtTo").Localized() }
        });
        Html.RenderPartial("_Search", (int)(Model.Author != null 
            ? JDM.Int32(Model.Author.EntityID)
            : 0));
    }
    </section>
</div>
